using System;

namespace Slaks.Graphs.Algorithms.Wordnet
{
	public class WordnetSynonymGraphDistances: GraphDistanceBase
    {
        public WordnetSynonymGraphDistances() : base ()
        {
        }

        public WordnetSynonymGraphDistances(Graph one, Graph two) 
            : base ( one, two )
        {
        }     

		/// <summary>
		/// MCS
		/// </summary>
		/// <param name="one"></param>
		/// <param name="two"></param>
		/// <returns></returns>
        public override double GetDistance()
		{
            double maxCommonSubgraphSize = one.GetMCS(two).GetGraphSizeVertexEdgeCount;
			double graphSizeOne = one.GetGraphSizeVertexEdgeCount;
			double graphSizeTwo = two.GetGraphSizeVertexEdgeCount;
			if (maxCommonSubgraphSize == 0.0) return 1;
			return 1 - maxCommonSubgraphSize/Math.Max(graphSizeOne, graphSizeTwo);
		}
	}
}